package ${conf.base_package}.${conf.controller_package};
<#-- 实体类的名称大写：Supplier -->
<#assign beanName = table.beanName/>
<#-- beanName 小写: supplier -->
<#assign beanNameUncap_first = beanName?uncap_first/>
<#-- 所有信息 -->
<#assign propertysAndColumnInfos = table.propertysAndColumnInfos/>
<#--<#assign implName = beanNameUncap_first+"Service"/>-->
import ${conf.client_package}.${beanName}Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ${conf.resp_package}.${beanName}Resp;
import ${conf.req_package}.${beanName}ListReq;
import ${conf.req_package}.${beanName}AddReq;
import ${conf.req_package}.${beanName}UpdateReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.gateon.hw.base.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
*  ${table.tableDesc} Controller层
* Created by ${conf.code_author} on ${.now}
*/
@Api(tags = "${table.tableDesc}")
@RestController
@RequestMapping(value = "/${beanNameUncap_first}")
public class ${beanName}Controller{

    @Autowired
    private ${beanName}Client ${beanNameUncap_first}Client;

    @ApiOperation(value = "查询${table.tableDesc}", notes = "查询${table.tableDesc}")
    @ApiImplicitParams({
    @ApiImplicitParam(paramType = "header", name = "X-UnionId", value = "微信unionId", required = true, dataType = "String"),
    @ApiImplicitParam(name = "req", value = "查询${table.tableDesc}-请求封装类", required = true, dataType = "${table.beanName}Req")
    })
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public Result<IPage<${beanName}Resp>> list(@RequestBody ${beanName}ListReq req) {
        <#--dto.setCompanyId(super.getCompanyId(request));-->
        return ${beanNameUncap_first}Service.list(req);
    }

    @ApiOperation(value = "查询${table.tableDesc}详情", notes = "查询${table.tableDesc}详情")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "${table.tableDesc}ID", required = true,  paramType = "path",dataType = "int")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Result<${beanName}Resp> getById(@PathVariable("id") Long id) {
        return ${beanNameUncap_first}Service.detail(id);
    }

    @ApiOperation(value = "添加${table.tableDesc}", notes = "添加${table.tableDesc}")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "req", value = "添加${table.tableDesc}-请求封装类", required = true, dataType = "${table.beanName}AddReq")
    })
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result insert(@RequestBody ${table.beanName}AddReq req) {
        return ${beanNameUncap_first}Service.add(req);
    }


    @ApiOperation(value = "更新${table.tableDesc}", notes = "更新${table.tableDesc}")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "req", value = "更新${table.tableDesc}-请求封装类", required = true, dataType = "${table.beanName}UpdateReq")
    })
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result update(@RequestBody ${table.beanName}UpdateReq req) {
        return ${beanNameUncap_first}Service.update(req);
    }

    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除${table.tableDesc}", notes = "删除${table.tableDesc}")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "${table.tableDesc}ID", required = true,  paramType = "path",dataType = "int")
    })
    public Result delete(@PathVariable("id") String id) {
        return ${beanNameUncap_first}Service.delete(id);
    }

}
